﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using RrslLite.Net.Contracts;
using Message = RrslLite.Net.Messages.Message;

namespace RrslLite.Net.Proxies
{
    public class MessageProcessorProxy : ClientBase<IWcfMessageService>, IWcfMessageService
	{
		public MessageProcessorProxy() { }

		public MessageProcessorProxy(string endpointConfigurationName) : base(endpointConfigurationName) { }

		public MessageProcessorProxy(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { }

		public MessageProcessorProxy(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { }

		public MessageProcessorProxy(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { }

		public MessageProcessorProxy(InstanceContext callbackInstance) : base(callbackInstance) { }

		public MessageProcessorProxy(InstanceContext callbackInstance, string endpointConfigurationName) : base(callbackInstance, endpointConfigurationName) { }

		public MessageProcessorProxy(InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress) : base(callbackInstance, endpointConfigurationName, remoteAddress) { }

		public MessageProcessorProxy(InstanceContext callbackInstance, string endpointConfigurationName, EndpointAddress remoteAddress) : base(callbackInstance, endpointConfigurationName, remoteAddress) { }

        public MessageProcessorProxy(InstanceContext callbackInstance, Binding binding, EndpointAddress remoteAddress) : base(callbackInstance, binding, remoteAddress) { }

        public Message[] InvokeOperations(params Message[] messages)
		{
			return Channel.InvokeOperations(messages);
		}

		public void Dispose()
		{
			try
			{
				Close();
			}
			catch (Exception)
			{
				Abort();
			}
		}
	}
}
